<?php

namespace api\controller;

// +----------------------------------------------------------------------
// | 标签数据控制层
// +----------------------------------------------------------------------

use common\controller\VerifyController;
use common\exception\LogicException;
use common\service\TagService;
use think\Request;

class TagController extends VerifyController
{
    /**
     * @var TagService
     */
    private $tagService;

    public function __construct()
    {
        parent::__construct();
        $this->tagService = new TagService();
    }

    /**
     * 获取标签分类
     * @param Request $request
     * @return \think\Response|void
     */
    public function getCategory(Request $request)
    {
        try {
            $res = $this->tagService->tagService();
            return json(success_response("", $res));
        } catch (LogicException $e) {
            throw_strack_exception($e->getMessage(), $e->getCode());
        }
    }

    /**
     * 标签查询列表
     * @param Request $request
     * @return \think\Response|void
     */
    public function getList(Request $request)
    {
        try {
            $param = $request->post();
            $res = $this->tagService->getList($param['param'] ?? []);
            return json(success_response("", $res));
        } catch (LogicException $e) {
            throw_strack_exception($e->getMessage(), $e->getCode());
        }
    }
}
